package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.Label;
import com.woniuxy.oldmanapi.mapper.LabelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LabelService {
    @Autowired
    LabelMapper labelMapper;

    public List<Label> selectAllLabel() {
        return labelMapper.selectAll();
    }

    public PageInfo<Label> selectLabelByCons(int now, int size, String labeltype) {
        PageHelper.startPage(now,size);
        List<Label> list = labelMapper.selectLabelByCons(labeltype);
        PageInfo<Label> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    public void updateLabel(Label label) {
        labelMapper.updateByPrimaryKey(label);
    }

    public void deleteLabel(Label label) {
        labelMapper.delete(label);
    }

    public void insertLabel(Label label) {
        labelMapper.insert(label);
    }
}
